import java.util.Scanner;

//将一个给定字符串 s 根据给定的行数 numRows ，以从上往下、从左到右进行 Z 字形排列。
public class test3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int n = in.nextInt();
        System.out.println(convert(str,n));
    }
    public static String convert(String s, int numRows) {
        if(numRows==1){
            return s;
        }
        int d = 2*numRows-2,n = s.length();
        StringBuilder stringBuilder = new StringBuilder();
        //处理第一行
        for (int i = 0; i < n; i+=d) {
            stringBuilder.append(s.charAt(i));
        }
        //处理中间行数
        for (int k = 1; k < numRows-1; k++) {
            for (int i = k,j=d-k; i < n||j<n; i+=d,j+=d) {
                if(i<n) stringBuilder.append(s.charAt(i));
                if(j<n) stringBuilder.append(s.charAt(j));
            }
        }
        //处理最后一行
        for (int i = numRows-1; i < n; i+=d) {
            stringBuilder.append(s.charAt(i));
        }
        return stringBuilder.toString();
    }
}